﻿@model StripeNET.StripeCustomer
@{
    ViewBag.Title = "Detail";
}

<h2>Customer Detail</h2>
<h3>Information</h3>
<table class="table table-striped">
    <tr>
        <th>User ID</th>
        <td>@Model.CustomerId</td>
    </tr>
    @{string fullname = "";}
    @{string address = "";}
    @{string phone = "";}
    @if (Model.StripeShipping != null)
    {
        fullname = @Model.StripeShipping.FullName;
        address = @Model.StripeShipping.BillingAddress.Line1;
        phone = @Model.StripeShipping.Phone;
    }
    <tr>
        <th>Fullname</th>
        <td>@fullname</td>

    </tr>
    <tr>
        <th>Address</th>
        <td>@address</td>
    </tr>
    <tr>
        <th>Phone</th>
        <td>@phone</td>
    </tr>
    <tr>
        <th>Email</th>
        <td>@Model.Email</td>
    </tr>
    <tr>
        <th>Extra Customer Info</th>
        @{string extraInfo = "";}
        @if (Model.Metadata != null)
        {
            extraInfo = @Model.Metadata["ExtraCustomerInfo"];
        }
        <td>@extraInfo</td>
    </tr>
</table>
<h3>Transaction</h3>
<table class="table table-bordered">
    <tr>
        <th>Transaction ID</th>
        <th>Transaction date</th>
        <th>Transaction amount</th>
        <th>ExtraTransactionInfo</th>
        <th>Payment method name</th>
        <th>Card Number</th>
        <th>Transaction status</th>
    </tr>
    @foreach (var item in @ViewBag.StripeCharge)
    {
        float amount = (float)item.Amount / 100;
        <tr>
            <td>@item.ChargeId</td>
            <td>@item.Created.Day / @item.Created.Month / @item.Created.Year - @item.Created.TimeOfDay</td>
            <td>@amount</td>
            @if (@item.Metadata.ContainsKey("ExtraTransactionInfo"))
            {
                <td>@item.Metadata["ExtraTransactionInfo"]</td>
            }
            else
            {
                <td></td>
            }
            <td>@item.Source.Brand</td>
            <td>**** @item.Source.Last4</td>
            <td>@item.Status</td>
        </tr>
    }
</table>

<div>
    @Html.ActionLink("Back", "Index")
</div>